<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
    <link rel="shortcut icon" type="image/png" href="#{request.contextPath}/resources/images/favicon.ico"/>
    <title>User Profile</title>
    <link type="text/css" rel="stylesheet"
		href="#{request.contextPath}/resources/css/styles.css" />
</h:head> 
<h:outputScript library="js" name="blockui.js" target="head" />
<body>
    <div id="wrap">
        <div id="header">
			<ui:include src="/CommonHeader.xhtml"></ui:include>
		</div>
		<div id="inner-wrap">
			<div id="content">
				<p:growl id="meteocalMsg" life="3000" />
				<table style="width: 100%">
					<tr>
					<td style="width: 48%"><p:panel header="Profile">
								<h:form id="profile" >

                                                                      <h:panelGrid columns='3' columnClasses="column" cellpadding="8">

										<p:message for="usrName" />

										<h:outputLabel for='usrName' value='Name:' />
											<p:inputText id='usrName' value='#{userBean.user.name}' />
										<p:message for="usrName" />

										<h:outputLabel for='usrSurname' value='Surname:' />
                                                                                    <p:inputText id='usrSurname' value='#{userBean.user.surname}' />
										<p:message for="usrSurname" />

										<h:outputLabel for='usrMail' value='Email:' />				
											<p:inputText id='usrMail' value='#{userBean.user.email}'												
												validatorMessage="Invalid Email">
											<f:validateRegex pattern="[a-zA-Z0-9]+@[a-zA-Z]+.[a-zA-Z]{2,3}"></f:validateRegex></p:inputText>
                                                                                
                                                                                <p:message for="usrMail" />
                                                                                
                                                                                <h:outputLabel for='usrPhone' value='Phone:' />										
											<p:inputText id='usrPhone' value='#{userBean.user.phone}'												
												validatorMessage="Invalid Phone Number">
												<f:validateRegex pattern="[0-9]*"></f:validateRegex>
											</p:inputText>		
										<p:message for="usrPhone" />
                                                                                
                                                                                <h:outputLabel for='usrDescri' value='Description:' />										
                                                                                    <p:inputTextarea id='usrDescri' value='#{userBean.user.description}'>
											</p:inputTextarea>				
										<p:message for="usrDescri" />
                                                                                
                                                                                <h:outputLabel for='usrJob' value='Job:' />
										
                                                                                    <p:inputTextarea id='usrJob' value='#{userBean.user.job}'>
											</p:inputTextarea>
										
										<p:message for="usrJob" />

										<br></br>
										<p:commandButton action='#{userBean.updateUser()}'
											value='update' type="submit" ajax="false" styleClass="block" />
									</h:panelGrid>
								</h:form>
								<br></br>
								<br></br>
								<h:form id="change_passwd">
									<p:fieldset legend="Change Password" toggleable="true"
										toggleSpeed="500" collapsed="true">
										<p:growl id="SwimMsg" life="3000" />

										<h:panelGrid columns="3">
											<h:outputLabel for="oldpwd" value="Old Password: *" />
											<p:password id="oldpwd" value="#{userBean.oldpwd}"
												label="Old Password" />
											<p:message for="oldpwd" />
											<h:outputLabel for="newpwd" value="New Password: *" />
											<p:password id="newpwd" value="#{userBean.newpwd}"
												label="New Password" feedback="true">
											</p:password>
											<p:message for="newpwd" />
										</h:panelGrid>
										<p:commandButton action='#{userBean.updatePassword()}'
											value='update' type="submit" ajax="false" styleClass="block" />
									</p:fieldset>


								</h:form>
							</p:panel></td>					
					</tr>
				</table>
			</div>
		</div>
        </div>
</body>
</html>